package com.hibernate.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.javacommon.base.BaseEntity;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

/**
 * 
 */

@Entity
@Table(name = "REPORT_TITLE")
public class ReportTitle extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "广告效果报表标题定义";
	public static final String ALIAS_ID = "ID";
	public static final String ALIAS_USER_ID = "用户ID";
	public static final String ALIAS_NAME = "名称";
	public static final String ALIAS_IS_DEFAULT = "是否默认显示";
	public static final String ALIAS_CREATION_TIME = "创建时间";
	
	//date formats
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * ID       db_column: ID 
     */ 	
	
	private Long id;
    /**
     * 用户ID       db_column: USER_ID 
     */ 	
	@NotNull 
	private Long userId;
    /**
     * 名称       db_column: NAME 
     */ 	
	@NotBlank @Length(max=200)
	private String name;
	/**
     * XML字符串，保存了用户设置的标题的级别       db_column: XML 
     */ 	
	@NotBlank @Length(max=2000)
	private String xml;
    /**
     * 是否默认显示       db_column: IS_DEFAULT 
     */ 	
	@NotBlank @Length(max=1)
	private String isDefault;
    /**
     * 创建时间       db_column: CREATION_TIME 
     */ 	
	@NotBlank @Length(max=20)
	private String creationTime;
	/**
     * 创建时间       db_column: status 
     */ 	
	@NotBlank @Length(max=1)
	private int status;
	/**
     * 描述     db_column: description 
     */ 	
	@Length(max=2000)
	private String description;
	
	//columns END


	public ReportTitle(){
	}

	public ReportTitle(
		Long id
	){
		this.id = id;
	}

	

	public void setId(Long value) {
		this.id = value;
	}
	
	@Id 	@GeneratedValue(generator = "paymentableGenerator")       
	@GenericGenerator(name = "paymentableGenerator", strategy = "native") 
	@Column(name = "ID", unique = true, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getId() {
		return this.id;
	}
	
	@Column(name = "USER_ID", unique = false, nullable = false, insertable = true, updatable = false, length = 20)
	public Long getUserId() {
		return this.userId;
	}
	
	public void setUserId(Long value) {
		this.userId = value;
	}
	
	@Column(name = "NAME", unique = false, nullable = false, insertable = true, updatable = true, length = 200)
	public String getName() {
		return this.name;
	}
	
	public void setName(String value) {
		this.name = value;
	}
	
	@Column(name = "IS_DEFAULT", unique = false, nullable = false, insertable = true, updatable = true, length = 1)
	public String getIsDefault() {
		return this.isDefault;
	}
	
	public void setIsDefault(String value) {
		this.isDefault = value;
	}
	
	@Column(name = "CREATION_TIME", unique = false, nullable = false, insertable = true, updatable = false, length = 20)
	public String getCreationTime() {
		return this.creationTime;
	}
	
	public void setCreationTime(String value) {
		this.creationTime = value;
	}
	
//	private UserInfo userInfo;
//	public void setUserInfo(UserInfo userInfo){
//		this.userInfo = userInfo;
//	}
//	
//	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
//	@JoinColumns({
//		@JoinColumn(name = "USER_ID",nullable = false, insertable = false, updatable = false) 
//	})
//	public UserInfo getUserInfo() {
//		return userInfo;
//	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("Id",getId())
			.append("UserId",getUserId())
			.append("Name",getName())
			.append("IsDefault",getIsDefault())
			.append("CreationTime",getCreationTime())
			.append("Description", getDescription())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof ReportTitle == false) return false;
		if(this == obj) return true;
		ReportTitle other = (ReportTitle)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.isEquals();
	}

	public void setXml(String xml) {
		this.xml = xml;
	}
	
	@Column(name = "XML", unique = false, nullable = false, insertable = true, updatable = true, length = 2000)
	public String getXml() {
		return xml;
	}

	public void setStatus(int status) {
		this.status = status;
	}
	@Column(name = "STATUS", unique = false, nullable = false, insertable = true, updatable = true, length = 1)
	public int getStatus() {
		return status;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	@Column(name = "DESCRIPTION", unique = false, nullable = true, insertable = true, updatable = true, length = 2000)
	public String getDescription() {
		return description;
	}
	@Transient
	@Override
	public String getTarget() {
		// TODO Auto-generated method stub
		return null;
	}
	@Transient
	@Override
	public Long getTargetId() {
		// TODO Auto-generated method stub
		return null;
	}
	@Transient
	@Override
	public String getTargetName() {
		// TODO Auto-generated method stub
		return null;
	}
}

